package com.xll.controller;

import com.xll.entity.SysPermission;
import com.xll.service.SysPermissionService;
import com.xll.utils.QueryInfo;
import com.xll.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.security.Permissions;

/**
 * 权限数据控制层
 */
@Api(tags = "权限数据")
@RestController
@RequestMapping("/permission")
public class SysPermissionController {
    @Autowired
    private SysPermissionService sysPermissionService;

    @ApiOperation(value = "分页查询")
    @PostMapping("/findPage")
    public Result findPage(@RequestBody QueryInfo queryInfo) {
        return sysPermissionService.findPage(queryInfo);
    }

    @ApiOperation(value = "添加权限")
    @PostMapping("/insert")
    public Result insert(@RequestBody SysPermission permission) {
        return sysPermissionService.insert(permission);
    }

    @ApiOperation(value = "修改权限")
    @PutMapping("/update")
    public Result update(@RequestBody SysPermission permission) {
        return sysPermissionService.update(permission);
    }

    @ApiOperation(value = "删除权限")
    @DeleteMapping("/delete/{id}")

    public Result delete(@PathVariable("id") Long id) {

        return sysPermissionService.delete(id);
    }

    @ApiOperation(value ="查询所有的权限" )
    @GetMapping("findAll")
    public Result findAll(){
          return sysPermissionService.findAll();
    }
}
